package org.bud.data.bit.fmt;

import org.bud.data.bit.check.CheckData;
import org.bud.data.bit.fmt.BaseFmtData;

import java.util.Optional;
import java.util.function.Function;
import java.util.function.UnaryOperator;

/**
 * @author shaun
 * @date 2024/7/21
 * @instruction excel最后执行的一种数据格式处理
 */
public class StringFmt extends BaseFmtData<String> {
    @Override
    protected CheckData def() {
        return (data,key) -> true;
    }

    @Override
    protected UnaryOperator<String> fmt() {
        return r -> r;
    }

    @Override
    public Function<String, ?> fain() {
        return s -> s;
    }

    @Override
    public String origin(Object obj) {
        return Optional.ofNullable(obj)
                .map(Object::toString).orElse(null);
    }

}
